/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.pucp.Maestros.Vista;

import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.JFrame;
import javax.swing.table.DefaultTableModel;
import pe.edu.pucp.Maestros.Controlador.MaestroVueloControlador;
import pe.edu.pucp.Modelo.Aeropuerto;
import pe.edu.pucp.Modelo.Ciudad;
import pe.edu.pucp.Modelo.Continente;
import pe.edu.pucp.Modelo.Pais;
import pe.edu.pucp.Modelo.Permiso;
import pe.edu.pucp.Modelo.Vuelo;
import pe.edu.pucp.Util.Constante;
import pe.edu.pucp.Util.ValHelper;

/**
 *
 * @author Pedro
 */
public class MaestoVueloGUI extends javax.swing.JPanel {

    private JFrame padre;
    private MaestroVueloControlador c;    
    
    public MaestoVueloGUI() {
        initComponents();
    }
    
    
    public JFrame getPadre()
    {
        return padre;
    }
    
    public void addAbrifFileListener(ActionListener listener) {
        txtPath.addActionListener(listener);
    }
    
    public void setNombrePathArchivo(String path) {
        this.txtPath.setText(path);
    }    
    
    public void mostrarPermisos(ArrayList<Permiso> list){            
            if (!list.isEmpty()){                                
                btnCargarVuelo.setEnabled(buscarPermiso(list,Constante.P_ADM_CARV_CARGAR)==1);
                btnBuscarVuelo.setEnabled(buscarPermiso(list,Constante.P_ADM_CARV_BUSCAR)==1);
                btnMostrarVuelo.setEnabled(buscarPermiso(list,Constante.P_ADM_CARV_MOSTRAR)==1);
                btnSeleccionarArchivo.setEnabled(buscarPermiso(list,Constante.P_ADM_CARV_ABRIR)==1);
            }
    }    
  
    public int buscarPermiso(ArrayList<Permiso> list, int idel){
        int per=-1;
        for (Permiso opc : list){
            if (opc.getElemento().getIdelemento()==idel){ per =opc.getPermiso(); }
        }
        return per;
    }  
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        tbVuelo = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblResultadosResumen = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tblResultadosConsulta = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        cmbContinente = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        cmbPais = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        cmbCiudad = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        cmbAeropuerto = new javax.swing.JComboBox();
        btnBuscarVuelo = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jdcFechaFin = new com.toedter.calendar.JDateChooser();
        jLabel6 = new javax.swing.JLabel();
        jdcFechaInicio = new com.toedter.calendar.JDateChooser();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        btnSeleccionarArchivo = new javax.swing.JButton();
        txtPath = new javax.swing.JTextField();
        btnMostrarVuelo = new javax.swing.JButton();
        btnCargarVuelo = new javax.swing.JButton();

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "PaisOrigen", "PaisDestino", "Fecha Salida", "Fecha Llegada"
            }
        ));
        jTable1.setColumnSelectionAllowed(true);
        jTable1.setSurrendersFocusOnKeystroke(true);
        jScrollPane1.setViewportView(jTable1);

        setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        setMaximumSize(new java.awt.Dimension(764, 700));
        setMinimumSize(new java.awt.Dimension(764, 700));
        setPreferredSize(new java.awt.Dimension(764, 700));

        tbVuelo.setBorder(null);
        tbVuelo.setAutoscrolls(true);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        jPanel4.setAutoscrolls(true);

        tblResultadosResumen.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "PAIS", "CIUDAD", "SALIDA", "LLEGADA", "COSTO"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane2.setViewportView(tblResultadosResumen);
        tblResultadosResumen.getColumnModel().getColumn(0).setResizable(false);
        tblResultadosResumen.getColumnModel().getColumn(1).setResizable(false);
        tblResultadosResumen.getColumnModel().getColumn(2).setResizable(false);
        tblResultadosResumen.getColumnModel().getColumn(3).setResizable(false);
        tblResultadosResumen.getColumnModel().getColumn(4).setResizable(false);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 704, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)
                .addContainerGap())
        );

        tbVuelo.addTab("Lista de Vuelos", jPanel4);

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        jPanel5.setAutoscrolls(true);

        tblResultadosConsulta.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "PAIS", "CIUDAD", "SALIDA", "LLEGADA", "COSTO"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                true, false, true, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane5.setViewportView(tblResultadosConsulta);
        tblResultadosConsulta.getColumnModel().getColumn(0).setResizable(false);
        tblResultadosConsulta.getColumnModel().getColumn(1).setResizable(false);
        tblResultadosConsulta.getColumnModel().getColumn(2).setResizable(false);
        tblResultadosConsulta.getColumnModel().getColumn(3).setResizable(false);
        tblResultadosConsulta.getColumnModel().getColumn(4).setResizable(false);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 704, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)
                .addContainerGap())
        );

        tbVuelo.addTab("Resumen de Carga", jPanel5);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Ciudad Origen"));

        jLabel2.setText("Continente:");

        jLabel9.setText("País:");

        jLabel10.setText("Ciudad: ");

        jLabel4.setText("Aeropuerto : ");

        btnBuscarVuelo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recurso/search.png"))); // NOI18N
        btnBuscarVuelo.setToolTipText("Consultar vuelos");

        jLabel5.setText("Hasta:");

        jdcFechaFin.setDate(new Date());

        jLabel6.setText("Desde:");

        jdcFechaInicio.setDate(new Date());

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(jLabel10)
                            .addComponent(jLabel2))
                        .addGap(20, 20, 20))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(cmbAeropuerto, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnBuscarVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(cmbCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cmbPais, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cmbContinente, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jdcFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jdcFechaFin, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jdcFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6)
                            .addComponent(cmbContinente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(cmbPais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9)
                            .addComponent(jLabel5)
                            .addComponent(jdcFechaFin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(cmbCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jLabel4)
                            .addComponent(cmbAeropuerto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(99, 99, 99)
                        .addComponent(btnBuscarVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos de la Carga"));

        jLabel1.setFont(new java.awt.Font("Ubuntu", 0, 15)); // NOI18N
        jLabel1.setForeground(java.awt.Color.gray);
        jLabel1.setText("Archivo XML:");

        btnSeleccionarArchivo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recurso/folder.png"))); // NOI18N
        btnSeleccionarArchivo.setToolTipText("Seleccionar Archivo");

        txtPath.setEditable(false);

        btnMostrarVuelo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recurso/zoom_in.png"))); // NOI18N
        btnMostrarVuelo.setToolTipText("Mostrar Carga");

        btnCargarVuelo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recurso/checkmark.png"))); // NOI18N
        btnCargarVuelo.setToolTipText("Iniciar Carga");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(36, 36, 36)
                .addComponent(txtPath, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnSeleccionarArchivo, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnMostrarVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnCargarVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnSeleccionarArchivo, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(btnCargarVuelo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btnMostrarVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(0, 0, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(tbVuelo, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tbVuelo)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

       
    // Agregar escucha para boton de seleccion de archivos
    public void addSeleccionarArchivo(ActionListener listener)
    {
        this.btnSeleccionarArchivo.addActionListener(listener);
    }
    
        
    // Agregar escucha para boton de Mostrar los vuelos a cargar
    public void addMostrarVuelosAcargar(ActionListener listener)
    {
        this.btnMostrarVuelo.addActionListener(listener);
    }
    
    // Agregar escucha para boton de Carga de Vuelos
    public void addCargarVuelos(ActionListener listener)
    {
        this.btnCargarVuelo.addActionListener(listener);
    }
    
    public void addBuscarVuelos(ActionListener listener)
    {
        this.btnBuscarVuelo.addActionListener(listener);
    }
    
    // Agregar escucha para busqueda de aeropuertos
    public void addCambiarContinente(ItemListener ml)
    {
        this.cmbContinente.addItemListener(ml);
    }
    
    public void addCambiarPais(ItemListener ml)
    {
        this.cmbPais.addItemListener(ml);
    }      
    
    public void addCambiarCiudad(ItemListener ml){
        this.cmbCiudad.addItemListener(ml);
    }      
    
    public void addCambiarAeropuerto(ItemListener ml){
        this.cmbAeropuerto.addItemListener(ml);
    }  
     
    public Date getFechaInicio()
    {
        return jdcFechaInicio.getDate();
    }
    
    public Date getFechaFin()
    {
        return jdcFechaFin.getDate();
    }
    
    public void setFechaFin(Date d)
    {
        jdcFechaFin.setDate(d);
    }
    
    public void setFechaInicio(Date d)
    {
        jdcFechaInicio.setDate(d);
    }
    
    public int getAeropuerto()
    {
        return cmbAeropuerto.getSelectedIndex();
    }
    
    public int getCiudad(){
        return cmbCiudad.getSelectedIndex();
    } 
    
    public int getPais(){
        return cmbPais.getSelectedIndex();
    }     
    
    public int getContinente(){
        return cmbContinente.getSelectedIndex();
    }
    
    public String getNombreArchivo(){
        return txtPath.getText();
    }
    
    public void setNombreArchivo(String ruta )
    {
        txtPath.setText(ruta);
    }
    
    public void llenarComboContinente(ArrayList<Continente> lista){
        cmbCiudad.removeAllItems();
        if(lista!=null){
            for (Continente opc : lista){
                cmbContinente.addItem(opc.getDescripcion());
            }
        }
    }
    
    public void llenarComboPais(ArrayList<Pais> lista){
        cmbPais.removeAllItems();
        if(lista!=null){           
            for (Pais opc : lista){
                cmbPais.addItem(opc.getDescripcion());
            }
        }
    }    
    
    public void llenarComboCiudad(ArrayList<Ciudad> lista){
        cmbCiudad.removeAllItems();
        if(lista!=null){           
            for (Ciudad opc : lista){
                cmbCiudad.addItem(opc.getDescripcion());
            }
        }
    }
    
    public void llenarComboAeropuerto(ArrayList<Aeropuerto> lista){
        cmbAeropuerto.removeAllItems();
        if(lista!=null){           
            for (Aeropuerto opc : lista){
                cmbAeropuerto.addItem(opc.getDescripcion());
            }
        }
    }
    
    public void llenaGrillaResumen(ArrayList<Vuelo> lista){        
        SimpleDateFormat formato = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");        
        if(lista!=null){ 
            ((DefaultTableModel) this.tblResultadosResumen.getModel()).setRowCount(tblResultadosResumen.getRowCount()+1);
            for (int f = 0; f<lista.size();f++){
                ((DefaultTableModel) tblResultadosResumen.getModel()).setRowCount(tblResultadosResumen.getRowCount()+1);
               
                tblResultadosResumen.setValueAt(lista.get(f).getAeropuertoByIddestino().getCiudad().getPais().getDescripcion(),f,0);
                tblResultadosResumen.setValueAt(lista.get(f).getAeropuertoByIddestino().getCiudad().getDescripcion(),f,1);
                tblResultadosResumen.setValueAt(formato.format(lista.get(f).getSalidaest()),f,2);    
                tblResultadosResumen.setValueAt(formato.format(lista.get(f).getLlegadaest()),f,3);    
                tblResultadosResumen.setValueAt(Math.round(lista.get(f).getCosto()),f,4);    
            }            
            tbVuelo.setTitleAt(0, "Lista de Vuelos (" + lista.size() + ")");
        } else {
            tbVuelo.setTitleAt(0, "Lista de Vuelos");            
        }    
        ((DefaultTableModel) this.tblResultadosConsulta.getModel()).setRowCount(0);
    }
    
    public void llenaGrillaConsulta(ArrayList<Vuelo> lista){
        SimpleDateFormat formato = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");             
        if(lista!=null){ 
            ((DefaultTableModel) this.tblResultadosConsulta.getModel()).setRowCount(0);
            for (int f = 0; f<lista.size();f++){
                ((DefaultTableModel) tblResultadosConsulta.getModel()).setRowCount(tblResultadosConsulta.getRowCount()+1);
               
                tblResultadosConsulta.setValueAt(lista.get(f).getAeropuertoByIddestino().getCiudad().getPais().getDescripcion(),f,0);
                tblResultadosConsulta.setValueAt(lista.get(f).getAeropuertoByIddestino().getCiudad().getDescripcion(),f,1);
                tblResultadosConsulta.setValueAt(formato.format(lista.get(f).getSalidaest()),f,2);    
                tblResultadosConsulta.setValueAt(formato.format(lista.get(f).getLlegadaest()),f,3);    
                tblResultadosConsulta.setValueAt(Math.round(lista.get(f).getCosto()),f,4);    
            }
            tbVuelo.setTitleAt(1, "Resumen de Carga (" + lista.size() + ")");
        } else {
            tbVuelo.setTitleAt(1, "Resumen de Carga");            
        }
        ((DefaultTableModel) this.tblResultadosResumen.getModel()).setRowCount(0);
    }
    
    public void mostrarAvisoError(String msn){ ValHelper.mostrarAviso(msn); }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscarVuelo;
    private javax.swing.JButton btnCargarVuelo;
    private javax.swing.JButton btnMostrarVuelo;
    private javax.swing.JButton btnSeleccionarArchivo;
    private javax.swing.JComboBox cmbAeropuerto;
    private javax.swing.JComboBox cmbCiudad;
    private javax.swing.JComboBox cmbContinente;
    private javax.swing.JComboBox cmbPais;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTable jTable1;
    private com.toedter.calendar.JDateChooser jdcFechaFin;
    private com.toedter.calendar.JDateChooser jdcFechaInicio;
    private javax.swing.JTabbedPane tbVuelo;
    private javax.swing.JTable tblResultadosConsulta;
    private javax.swing.JTable tblResultadosResumen;
    private javax.swing.JTextField txtPath;
    // End of variables declaration//GEN-END:variables
}
